<template>
  <div class="app-container">
    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
      <div style="background: #f5f8fa; border-radius: 6px 6px 0 0; padding: 10px 0 10px 0;">
        <el-row type="flex" justify="center">
          <el-col :span="4" style="text-align:center;font-weight:bold;">用户id</el-col>
          <el-col :span="4" style="text-align:center;font-weight:bold;">用户头像</el-col>
          <el-col :span="4" style="text-align:center;font-weight:bold;">用户昵称</el-col>
          <el-col :span="4" style="text-align:center;font-weight:bold;">砍价金额</el-col>
          <el-col :span="8" style="text-align:center;font-weight:bold;">砍价时间</el-col>
        </el-row>
      </div>
      <div style="padding: 16px 0;">
        <el-row type="flex" justify="center" align="middle">
          <el-col :span="4" style="text-align:center;">{{ formData.uid }}</el-col>
          <el-col :span="4" style="text-align:center;">
            <el-avatar :src="formData.avatar" size="large" />
          </el-col>
          <el-col :span="4" style="text-align:center;">{{ formData.nickname }}</el-col>
          <el-col :span="4" style="text-align:center;">{{ formData.bargainPrice }}</el-col>
          <el-col :span="8" style="text-align:center;">{{ parseTime(formData.addTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</el-col>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import * as BargainUserApi from '@/api/store/bargainuser';
  import { parseTime } from '@/utils/ruoyi';
  export default {
    name: "BargainUserForm",
    components: {},
    data() {
      return {
        dialogTitle: "查看详情",
        dialogVisible: false,
        formLoading: false,
        formData: {},
      };
    },
    methods: {
      parseTime(time, pattern) {
        return parseTime(time, pattern);
      },
      async open(id) {
        this.dialogVisible = true;
        this.formData = {};
        if (id) {
          this.formLoading = true;
          try {
            const res = await BargainUserApi.getBargainUser(id);
            this.formData = res.data;
          } finally {
            this.formLoading = false;
          }
        }
      }
    }
  };
</script>
